% TEST_ID: LANG-EXPAND-0130
% CATEGORY: language/string
% 测试 string 的删除

function test_string_strtrim()
chr = sprintf('  \t   Remove    leading whitespace');
newChr = strtrim(chr);
ret = 'Remove    leading whitespace';
assert(isequal(newChr, ret));

chr = sprintf('  \t   Remove    leading whitespace');
newChr = strtrim(chr);
result = 'Remove    leading whitespace';
assert_istrue(result, newChr);

str = string({'   Gemini    ','   Apollo    ';
       '   ISS       ','   Skylab    '});
newStr = strtrim(str);
result = string({'Gemini'    'Apollo'
    'ISS'       'Skylab'});
assert_istrue(result, newStr);

chr = string({'     Trim leading whitespace';
       'Trim trailing whitespace     '});
newChr = strtrim(chr);
result1 = string({'Trim leading whitespace' });
result2 = string({'Trim trailing whitespace'});
assert_istrue(newChr(1), result1);
assert_istrue(newChr(2), result2);

chr = ['  ';'  '];
assert(isempty(strtrim(chr)))

chr = [sprintf('\t'); ' '];
assert(isempty(strtrim(chr)))
end

function assert_istrue(x,y)
    assert(isequal(x, y));
end